//
//  ViewController.m
//  DesEncryption
//
//  Created by weihong xuan on 2015/12/14.
//  Copyright © 2015年 weihong xuan. All rights reserved.
//

#import "ViewController.h"
#import "WHDesOperation.h"


@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    NSString * testStr = @"你好nihao";
    NSString * desKey = @"12345678";//加密运算、解密运算时所使用的密钥
    
    NSString * encStr = [WHDesOperation encryptUseDES:testStr key:desKey isHaveRandomNumber:YES];
    //nXejkN+fm9otBxUag1Gp9g==
    //nXejkN+fm9otBxUag1Gp9g==
    //2DpXsyYMO4m+BdzM1VR0Oxgt3K/z4VJR
    //ee5gBAG+XMzAklpLRELCaqOCxovGWKd5
    //CyZ0zHYPk88=
    NSLog(@"加密后的字符串：%@",encStr);
    
    NSString * decStr = [WHDesOperation decryptUseDES:encStr key:@"12345678" isHaveRandomNumber:YES];
    NSLog(@"密码错误时解密后的字符串：%@",decStr);

    decStr = [WHDesOperation decryptUseDES:encStr key:@"00123456" isHaveRandomNumber:NO];
    NSLog(@"密码正确时随机数错误时 解密后的字符串：%@",decStr);

    decStr = [WHDesOperation decryptUseDES:@"DE0ADAC5C7736F98123AF8B0EFBF5A6E79AFB7C1D828508263EEE476E301327B" key:@"zhao98cn" isHaveRandomNumber:NO];
    NSLog(@"正确解密后的字符串：%@",decStr);


    NSString * decStrTmp = [WHDesOperation encryptWithContent:@"你好nihao" type:0 key:@"12345678"];
    NSLog(@"decStrTmp加密后的字符串：%@",decStrTmp);
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
